package April._19.work4;

import java.io.BufferedReader;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.util.Arrays;
import java.util.Arrays;
import java.util.stream.Stream;

public class Main {
    public static void main(String[] args) throws IOException {
        FileReader in = null;
        FileWriter out = null;
        try {
            in = new FileReader("fileTest\\a.txt");
            char[] chars = new char[1024];
            //如何实现一次读一行
            int read = in.read(chars);
            if (read != -1) {
                reverseChar(chars, read);
                out = new FileWriter("fileTest\\b.txt");
                out.write(chars, 0, read);
            }


        } finally {
            if (in != null) {
                in.close();
            }
            if (out != null) {
                out.close();
            }
        }
    }

    private static void reverseChar(char[] chars, int read) {
        for (int i = 0; i < read / 2; i++) {
            char temp = chars[i];
            chars[i] = chars[read - 1 - i];
            chars[read - 1 - i] = temp;
        }
    }
}
